package com.spring.service.impl;
import com.spring.service.MailService;

import com.spring.until.KeyUtil;
import org.json.JSONObject;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;

@Service
public class MailServiceImpl implements MailService {

    @Override
    public int sendEmail(HttpServletRequest request) {
        String toMail = request.getParameter("email") ;
        String code = KeyUtil.keyUtils();
        String res;
        //EmailUtil emailUtil = new EmailUtil() ;
        //boolean ok = emailUtil.sendMail(toMail,code);
        boolean ok = true ;
        if (ok) {
            JSONObject json = new JSONObject();
            json.put("Code", code);
            json.put("createTime", System.currentTimeMillis());
            request.getSession().setAttribute("EmailCode", json);
            return 1 ;
        }
        return 0 ;
    }
}